<%@ page language="java" import="java.util.*,com.sirenbang.easyshop.config.*" pageEncoding="utf-8"%>
<%@ include  file="/jsps/front/common/taglibs.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>你的购物车信息</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">

		<link rel="stylesheet" type="text/css"  href="<c:url value="/jsps/front/css/show_shopping_cart.css"/>">
		<link rel="stylesheet" type="text/css"  href="<c:url value="/jsps/front/css/shop_main.css"/>">
        <link rel="stylesheet" type="text/css"  href="<c:url value="/jsps/front/css/head.css"/>">
		<link rel="stylesheet" type="text/css" href="<c:url value="/jsps/front/css/application.css"/>">
		<script type="text/javascript" src="<c:url value="/js/jquery.js"/>"></script>
		<script type="text/javascript" src="<c:url value="/js/payfor.js"/>"></script>
		
		<script type="text/javascript">

		function onlynumber() {
			if (event.keyCode==13){
				return true;
			}
			if (event.keyCode<48||event.keyCode>57){
				event.keyCode=0;
				event.returnValue=false;
			}
			event.returnValue=true;
		}

	    var prices=0;
	    function accountPrice(id,i) {
	    	// alert("$n(quantity,0).value:"+$n("quantity",0).value);
	    	var num=$n("quantity",i).value;
	    	//alert("num:"+num);
	    	// alert("num*price:"+num*price);
	    	// alert("$(totalPrices):"+$("totalPrices"));
	    	// $("totalPrices").innerText=num*price;
	    	// prices+=num*price;
	    	location.href="<c:url value="/goodMgr?act=setQuantity&id="/>"+id+"&quantity="+num;
	    };
	    
	    function getPrices() {
	    	$("totalPrices").innerText=prices.toFixed(1);
	    };
	    
	    function setNewItemAmount(goodsid,amount,totalAmount)
	    {
	       //alert(totalAmount);
	       if(amount<1 || totalAmount<amount)
	       {
	            alert("请输入1--"+totalAmount+"的整数!");
	            location.href="<c:url value="/goodMgr?act=refresh"/>";
	       }
	       else 
	       location.href="<c:url value="/goodMgr?act=setNewItemAmount&goodNo="/>"+goodsid+"&cnt="+amount;
	    };
	    
	   function removeGoodFromCar(goodsid,goodsname)
	    {
	      if(confirm("您真的要删除购物车中的商品条目["+goodsname+"]吗?"))
	        location.href="<c:url value="/goodMgr?act=removeGoodFromCar&goodNo="/>"+goodsid;
	   }
	   
	    function setAmount.reduce(goodsid,index){
	       var amount=document.getElementById('goodNum'+index).value;
	         //alert(amount);
	         amount--;
	         if(amount<1)
	           alert("你输入的值要大于等于1!");
	         else 
	        location.href="<c:url value="/goodMgr?act=setNewItemAmount&goodNo="/>"+goodsid+"&cnt="+amount;
	    }
	 function setAmount.add(goodsid,totalAmount,index){
	       var amount=document.getElementById('goodNum'+index).value;
	       //alert(amount);
	         amount++;
	       //alert(totalAmount);
	         
	         if(amount>totalAmount)
	           alert("你输入的值要小于等于"+totalAmount+"件!");
	         else 
	        location.href="<c:url value="/goodMgr?act=setNewItemAmount&goodNo="/>"+goodsid+"&cnt="+amount;
	    }
	 
	</script>

	</head>

	<body style="background-color: #769b72;">
		<div id="allcontent">

			<div>
				<c:import url="/jsps/front/head.jsp"/>
			</div>

			<DIV class=my_shopping>
				<IMG class=pic_shop title=我的购物车
					src="<c:url value="/jsps/front/images/home/pic_myshopping.gif" />">
				<DIV class="shop_news t_red" id=free_fee_tip>
					<A href="#" name=free_tip>全场免普通快递送货上门费和普通邮递费</A>
				</DIV>
			</DIV>
			<DIV class=choice_merch id=div_choice>
				<H4 id=cart_tips>
					&nbsp;您已选购以下商品
				</H4>
				<DIV class=choice_bord>
					<TABLE class=tabl_buy id=tbCartItemsNormal>
						<TBODY>
							<TR class=tabl_buy_title>
								<TD>
									<SPAN class=span_w2>商品图片</SPAN>
								</TD>
								<TD class=buy_td_3>
									<SPAN class=span_w2>商品编号</SPAN>
								</TD>
								<TD class=buy_td_5>
									<SPAN class=span_w2>商场价格</SPAN>
								</TD>
								<TD class=buy_td_2>
									<SPAN class=span_w2>数量</SPAN>
								</TD>
								<TD class=buy_td_1>
									<SPAN>删除</SPAN>
								</TD>
							</TR>
							<c:if test="${not empty cart.items}">
								<c:forEach var="item" items="${cart.items}"
									varStatus="idxStatus">
									<TR class=td_no_bord>
										<TD align=left>
										  
										  <A title=商品图片 target="_blank"
											href="<c:url value="/goodMgr?act=showGood&goodNo=${item.good.goodsNo}"/>" name=purchase_bk>
											 <img id=img style="width: 90px; height: 90px; align:center;" title="商品图片" 
											 src="<c:url value="/goodMgr?act=showGoodCover"/>&goodNo=${item.good.goodsNo}" border=0> </A>
										</TD>
										<TD class="buy_td_7 c_gray">
											${item.good.goodsNo}
										</TD>
										<TD class=buy_td_4 style="PADDING-LEFT: 12px;">
											￥${item.good.goodsPrice}
										</TD>
										<TD class=buy_td_2>
										  <div class="p_number">
											<div class="f_l add_chose">
												<a class="reduce" onClick="setAmount.reduce('${item.good.goodsNo}',${idxStatus.index});" href="javascript:void(0)">
												-</a>
												<input type="text" name="goodNum${idxStatus.index}" id="goodNum" class="text" 
												       value=${item.goodNum } onKeyPress="onlynumber();"
												        onblur="setNewItemAmount('${item.good.goodsNo}',this.value,'${item.good.cnt}')" />
												<a class="add" onClick="setAmount.add('${item.good.goodsNo}','${item.good.cnt}',${idxStatus.index});" href="javascript:void(0)">
												+</a>
											 </div>
										   </div>
										</TD>
										<TD class=buy_td_1>
											<span title="点击删除商品"
												onclick="removeGoodFromCar('${item.good.goodsNo}','${item.good.goodsName}');">
											    <img src="<c:url value="/jsps/front/images/trash.png"/>" border="0" align="absbottom" />	
											</span>
										</TD>
									</TR>
								</c:forEach>
							</c:if>
							<c:if test="${empty cart}">
								<TR>
									<TD colspan=6 class=no_select>
										您还没有挑选商品
									</TD>
								</TR>
							</c:if>
						</TBODY>
					</TABLE>
					<DIV class=objhide id=div_no_choice>
					</DIV>
					<DIV class=choice_balance>
						<DIV class=select_merch>
							<A onmouseover="" href="<c:url value="/goodMgr?act=main"/>" name=Continue
								target="_self">继续挑选商品&gt;&gt; </A><br>
						</DIV>
						<DIV class=total_balance>
							<DIV class=save_total>
								<DIV class=save_total_right>
									<SPAN class=t_add>商品金额总计：</SPAN>
									<SPAN class=c_red_b id=totalPrices>￥
									<fmt:formatNumber pattern="0.00" value="${cart.cartAmount}" />
									</SPAN>
								</DIV>
							</DIV>
							<DIV class=balance id=balance>

								<A href="<c:url value="/goodMgr?act=showBalance"></c:url>"
									name=checkout> 
								<IMG title=结算 alt=结算
										src="<c:url value="/jsps/front/images/butt_balance.gif" />" border=0>
								</A>
							</DIV>
						</DIV>
					</DIV>
				</DIV>
			</DIV>
			<c:if test="${empty shoppingcar and not empty error}">
	            <script type="text/javascript">
                  alert('${error}');
                </script>
			</c:if>
		<div style="clear:both;"></div>
  <div id="footer" style="bottom:0px; margin-top:10px;width:960px;border-top:1px solid; COLOR: #404040;COLOR: #666; text-align:center; background-color:#fff;font-size:12px;">
	        <%=VersionInfo.buildFooterStr()%>           
	        </div>
</div>
	</body>
</html>
